package com.rokyinfo.pdm.entity;

import com.baomidou.mybatisplus.activerecord.Model;
import com.baomidou.mybatisplus.annotations.TableField;
import com.baomidou.mybatisplus.annotations.TableId;
import com.baomidou.mybatisplus.annotations.TableName;

import java.io.Serializable;
import java.util.Date;


/**
 * <p>
 * 设备型号表
 * </p>
 *
 * @author YuanZhiJian
 * @since 2017-01-21
 */
@TableName("d_model")
public class DModel extends Model<DModel> {

    public static final String SPECIALITY_BLUETOOTH = "0";
    public static final String SPECIALITY_RADIO = "1";

    private static final long serialVersionUID = 1L;

    @TableId("model_id")
    private Long modelId;
    /**
     * 分类 如：中控
     */
    private String category;
    /**
     * 型号名称
     */
    private String name;
    /**
     * 特性（多个用逗号分隔, 如0,1 ）
     */
    private String speciality;
    /**
     * 关联厂商ID
     */
    @TableField("firm_id")
    private Long firmId;
    /**
     * 创建时间
     */
    @TableField("create_time")
    private Date createTime;

    public String[] getSpecialityList() {
        if (speciality != null) {
            return speciality.split(",");
        }
        return null;
    }

    public boolean haveBluetoothSpeciality() {
        String[] temp = getSpecialityList();
        if (temp != null) {
            for (int i = 0; i < temp.length; i++) {
                if (temp[i].equals(SPECIALITY_BLUETOOTH)) return true;
            }
        }
        return false;
    }

    public boolean haveRadioSpeciality() {
        String[] temp = getSpecialityList();
        if (temp != null) {
            for (int i = 0; i < temp.length; i++) {
                if (temp[i].equals(SPECIALITY_RADIO)) return true;
            }
        }
        return false;
    }

    public Long getModelId() {
        return modelId;
    }

    public void setModelId(Long modelId) {
        this.modelId = modelId;
    }

    public String getCategory() {
        return category;
    }

    public void setCategory(String category) {
        this.category = category;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getSpeciality() {
        return speciality;
    }

    public void setSpeciality(String speciality) {
        this.speciality = speciality;
    }

    public Long getFirmId() {
        return firmId;
    }

    public void setFirmId(Long firmId) {
        this.firmId = firmId;
    }

    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    @Override
    protected Serializable pkVal() {
        return this.modelId;
    }

}
